<script setup lang="ts">
import ImageAside from '@/components/image/ImageAside.vue'
import ImageMain from '@/components/image/ImageMain.vue'
const windowHeight = window.innerHeight || document.body.clientHeight
const h = windowHeight - 64 - 50 - 20
const ImageAsideRef = ref(null)
const ImageMainRef = ref(null)
// 新增图片分类
function handleOpenCreate() {
  ImageAsideRef.value?.handleCreate()
}
// 上传图片
function handleOpenUpload() {
  ImageMainRef.value?.handleOpenUpload()
}
// 切换分类后加载图片
function handleAsideChange(class_id: number) {
  ImageMainRef.value?.loadData(class_id)
}
</script>

<template>
  <el-container class="body-container" :style="{ height: h + 'px' }">
    <el-header class="image-header">
      <el-button type="primary" @click="handleOpenCreate">新增图片分类</el-button>
      <el-button type="warning" @click="handleOpenUpload">上传图片</el-button>
    </el-header>
    <el-container>
      <ImageAside ref="ImageAsideRef" @change="handleAsideChange"></ImageAside>
      <ImageMain ref="ImageMainRef" />
    </el-container>
  </el-container>
</template>

<style lang="scss" scoped>
.body-container {
  background-color: #fff;
  border-radius: 5px;
  margin: 10px 20px;
  .image-header {
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
  }
}
</style>
